package com.key.controller.admin.analysisReport;

import com.github.pagehelper.PageHelper;
import com.key.common.R;
import com.key.common.vo.ACSVO;
import com.key.common.vo.SOCDVO;
import com.key.service.SOCDService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @Author：朕
 * @Package：com.key.controller.admin.analysisReport
 * @Project：ams_system
 * @name：SummaryOfCompanyDepartments
 * @Date：2023/2/18 9:07
 * @Filename：SummaryOfCompanyDepartments
 */
@Controller
@Api(value = "分析报表",tags = "公司部门汇总的API")
@RequestMapping("/SummaryOfCompanyDepartments")
public class SummaryOfCompanyDepartmentsController {

    @Autowired
    private SOCDService socdService;



    @RequestMapping(value = "/findSummaryOfCompanyDepartments",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "显示公司部门汇总",notes = "",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true)
    })
    public R findSummaryOfCompanyDepartments(Integer currentPage,Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        Map<String,Object> socdvos = socdService.findSOCD();
        if(socdvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(socdvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }



    @RequestMapping(value = "/findAssetTypeName",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "显示资产分类名称",notes = "",httpMethod = "get", response = R.class)
    public R findAssetTypeName(){
        R r = new R();
        String[] strings = socdService.findAssetTypeName();
        if(strings.length>0){
            r.setCode(200);
            r.setMsg("显示成功");
            r.setData(strings);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("显示失败");
            return r;
        }
    }




    @RequestMapping(value = "/findSummaryOfCompanyDepartmentsByType",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "通过资产的分类显示公司部门汇总",notes = "资产分类",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "assetTypeName",value = "资产分类名字",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true)
    })
    public R findSummaryOfCompanyDepartmentsByType(String assetTypeName,Integer currentPage,Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        Map<String,Object> socdvos = socdService.findSOCDByTypeName(assetTypeName);
        if(socdvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(socdvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }

    @RequestMapping(value = "/findSummaryOfCompanyDepartmentsById",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "通过公司编码显示公司部门汇总",notes = "公司编码",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Id",value = "公司编码",paramType = "query",dataType = "int",required = true),
    })
    public R findSummaryOfCompanyDepartmentsById(Integer Id){
        R r = new R();
        List<SOCDVO> acsvos = socdService.findBySOCDById(Id);
        if(acsvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(acsvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }



}

